package com.dunshan.hprose;

import hprose.client.HproseHttpClient;


/**
 * @author LiWen
 * @version 1.0
 * @Date: 2021-05-04 15:54
 * @Description:
 */
public class AppTestHp {

    public void mainStringrgs() {

        HproseHttpClient client = new HproseHttpClient();
        client.useService("http://localhost:8080/api/getUser");
        //通过接口调用
        IService service = client.useService(IService.class);
        String content = service.sayBye("7DGroup");
        System.out.println("rpc调用，返回：" + content);
    }


    public static void main(String[] args) throws Throwable {
        //new一个HproseHttpClient对象
        HproseHttpClient client = new HproseHttpClient();
        //使用无参构造器创建的客户端，在进行调用前，需要先调用useService方法初始化服务器地址
        client.useService("http://localhost:8080/api/getUser");
        //使用invoke方法来动态调用服务。
        String result = (String) client.invoke("sayHello", new Object[]{"Hprose"});
        System.out.println(result);

        result = (String) client.invoke("getUser", new Object[]{"7DGroup"});
        System.out.println(result);


        result = (String) client.invoke("sayBye", new Object[]{"7DGroup"});
        System.out.println(result);


    }


}
